﻿<template>
    <div>
        <div class="layout-main">
            <!-- <el-row style="margin-bottom:12px">
    <el-button v-on:click="add()" type="primary" size="small">添加</el-button>
</el-row> -->
            <el-form ref="queryParams" inline label-position="right" label-width="180px" v-model="queryParams">
                <el-form-item label="名称">
                    <el-input size="small" v-model="queryParams.name" placeholder="名称" style="width: 120px" @keyup.enter.native="search()" />
                </el-form-item>
                <el-form-item label="状态">
                    <el-input size="small" v-model="queryParams.status" placeholder="状态" style="width: 120px" @keyup.enter.native="search()" />
                </el-form-item>
                <el-form-item>
                    <el-button v-on:click="search()" type="primary" size="small">搜索</el-button>
                    <el-button v-on:click="reset()" size="small">重置</el-button>
                </el-form-item>
            </el-form>
            <!-- 
              <Table :loading="loading" :columns="columns" :data="disPartners" border>
            </Table>
            -->
            <el-table size="small" :data="disPartners" border style="width: 100%" v-loading="loading">
                <el-table-column type="selection" width="55">
                </el-table-column>
                <el-table-column align="center" prop="address" label="地址">
                </el-table-column>
                
                <el-table-column align="center" prop="contact" label="联系人">
                </el-table-column>
               
                <el-table-column align="center" prop="name" label="名称">
                </el-table-column>
             
                <el-table-column align="center" prop="phone" label="电话">
                </el-table-column>
              
                <el-table-column align="center" prop="remark" label="备注">
                </el-table-column>
             
                <el-table-column align="center" prop="status" label="状态">
                </el-table-column>
               
                <el-table-column align="center" prop="id" label="操作">
                    <template slot-scope="scope">
                        <el-button type="danger" @click="doDelete(scope.row)" size="small">删除</el-button>
                        <el-button type="primary" @click="edit(scope.row)" size="small">编辑</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div style="margin: 10px;overflow: hidden">
                <div style="float: right;">
                    <Page :page-size="page.pageSize" show-total :total="page.total" :current="page.current" @on-change="changePage"></Page>
                </div>
            </div>
        </div>
        <CDisPartnerDialog ref="disPartnerDialog" @cancel="getList()" @ok="getList()" />
    </div>
</template>
<script>
import CDisPartnerDialog from "./CDisPartnerDialog.vue"
import {getPartnerList} from "@/api/TradeApi"
export default {
    name: 'DisPartner',
    components: {
        CDisPartnerDialog
    },
    data() {
        return {
            loading: false,

            queryParams: {

            },
            others: {

            },
            DisPartner: {

            },
            page: {
                total: 0,
                current: 1,
                pageSize: 10
            },
            disPartners: [

            ],
            rules: {}
        };
    },
    mounted: function() {
        this.getList();

    },
    methods: {
        cbtime: function(value) {
            if (value) {
                this.queryParams.btime = value[0];
                this.queryParams.etime = value[1];
            } else {

            }
        },
        search: function() {
            this.page.current = 1;
            this.page.total = 0;
            this.getList();
        },
        reset: function() {
            this.queryParams = {};
            this.search();
        },
        changePage(current) {
            this.page.current = current;
            this.getList();
        },
        getList: function() {
            var me = this;
            var params = me.queryParams;
            params.current = me.page.current;
            params.pageSize = me.page.pageSize;
            me.loading = true;
            me.$http.post("/dispartner/getList.action", params).then(response => {
                var body = response;
                if (body.status == 0) {
                    me.page.total = body.obj.totalCount;
                    me.disPartners = body.obj.list;

                }
                me.loading = false;
            }, response => {
                me.loading = false;
            });
        },
        doDelete: function(id) {
            var me = this;
            me.$confirm('是否执行该操作, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                me.$http.post("/sys/dispartner/doDelete.action", { id: id }).then(response => {
                    var body = response;
                    if (body.status == 0) {
                        me.getList();

                    } else {
                        me.errorMessage(body.info);
                    }
                }).catch(error => {

                });
            }).catch(() => {});

        },
        edit: function(row) {
            this.disPartner = row;
            this.$refs['disPartnerDialog'].showDialog(row.id);
        },
        add: function() {
            this.disPartner = {};
            this.$refs['disPartnerDialog'].showDialog("");
        }

    }
}
</script>
<style scoped>
</style>